home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-01-14 | 1.8 KB | 65 lines | [TEXT/MPS ] |
- /* _________________________________________________________________________________________________________ //
- Copyright © 1992 Apple Computer, Inc. All rights reserved.
- Macintosh Developer Technical Support.C++ Macintosh Toolbox Framework.
- Originator: Kent Sandvik
- Date: Friday, July 10, 1992 10:14:13
- Revision comments are at the end of this file.
- ---
- TTracer is an example of a stack/heap based tracing class, which could be
- used for tracing memory leaks and keeping track of created objects
- TestTracer.cp contains test code for testing the TTracer class.
- _________________________________________________________________________________________________________ */
-
-
- // Include files
- #ifndef _TRACER_
- #include "Tracer.h"
- #endif
-
- // Function used for testing TTracer.
- void InvertPermutation(int* perm,
- int* inv,
- int max)
- {
- TTracer autoTracer("InvertPermutation function", TRACEPOINT);
-
- if (perm && (new TTracer("temp", TRACEPOINT))// show TTracer in action
- && inv && (new TTracer("temp2", TRACEPOINT))// these two are never destructed =
- && (max > 0)) // memory leak!
- {
- TTracer otherTracer("otherTracer", TRACEPOINT);
-
- for (int i = 0; i < max; i++)
- {
- TTracer thirdTracer("iterationTracing...", TRACEPOINT);
- inv[perm[i]] = i;
- }
- }
- }
-
-
- // Test code itself.
- void main(void)
- {
- cout << "The TTracer test is starting…\n";
-
- // Array declarations used in the test
- int perm[] = {
- 1, 2, 3, 6, 7};
- int max = 5;
-
- int* inv = new
- int[max];
- InvertPermutation(&perm[0], inv, max);
-
- cout << "The TTracer test ended!\n";
- }
-
- // _________________________________________________________________________________________________________ //
-
-
- /* Change History (most recent last):
- No Init. Date Comment
- 1 khs 7/10/92 New file
- */
-